package com.xinian.springclud_demo.exception;

import com.xinian.springclud_demo.common.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.ResultSet;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);


    @ExceptionHandler(value = BusinessException.class)
    public Result zdyExceptionHandeler (BusinessException e){
        System.out.println("全局异常1");
        log.error(e.getErrorMeg(),e);
        return Result.builder().data(e).build();
    }

    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e){
        System.out.println("全局异常2");
        log.error(e.getMessage(),e);
        return Result.builder().data(e).build();
    }


}
